package com.orkasgb.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.orkasgb.common.CommonResult;
import com.orkasgb.entity.OrkasgbProjectEntity;
import com.orkasgb.service.IOrkasgbProjectService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;
import java.util.List;

/**
 * 项目信息表(TOrkasgbProject)表控制层
 *
 * @version 1.0.0
 * @since 2024-09-08 21:17:17
 */
@RestController
@RequestMapping("orkasgbProject")
public class OrkasgbProjectController {
	
	/**
	 * 服务对象
	 */
	@Resource
	private IOrkasgbProjectService orkasgbProjectService;
	
	/**
	 * 通过主键查询单条数据
	 *
	 * @param id 主键
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbProject/{id}")
	public CommonResult<OrkasgbProjectEntity> getOrkasgbProject (@PathVariable("id") Serializable id) {
		return CommonResult.ofSuccess(orkasgbProjectService.getOrkasgbProject(id));
	}
	
	/**
	 * 通过条件查询多条数据
	 *
	 * @param orkasgbProject 实体查询参数
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbProjectList")
	public CommonResult<List<OrkasgbProjectEntity>> getOrkasgbProjectList (@ModelAttribute OrkasgbProjectEntity orkasgbProject) {
		return CommonResult.ofSuccess(orkasgbProjectService.getOrkasgbProjectList(orkasgbProject));
	}
	
	/**
	 * 通过条件查询多条数据(分页查询)
	 *
	 * @param orkasgbProject 查询参数
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbProjectPageDataList")
	public CommonResult<IPage<OrkasgbProjectEntity>> getOrkasgbProjectPageDataList (@ModelAttribute OrkasgbProjectEntity orkasgbProject) {
		return CommonResult.ofSuccess(orkasgbProjectService.getOrkasgbProjectPageDataList(orkasgbProject));
	}
	
	/**
	 * 新增数据
	 *
	 * @param orkasgbProject 实体对象
	 * @return 新增结果
	 */
	@PostMapping("addOrkasgbProject")
	public CommonResult<Integer> addOrkasgbProject (@RequestBody OrkasgbProjectEntity orkasgbProject) {
		return CommonResult.ofSuccess(orkasgbProjectService.addOrkasgbProject(orkasgbProject));
	}
	
	/**
	 * 修改数据
	 *
	 * @param orkasgbProject 实体对象
	 * @return 修改结果
	 */
	@PutMapping("updateOrkasgbProject")
	public CommonResult<Integer> updateOrkasgbProject (@RequestBody OrkasgbProjectEntity orkasgbProject) {
		return CommonResult.ofSuccess(orkasgbProjectService.updateOrkasgbProject(orkasgbProject));
	}
	
	/**
	 * 修改或者新增数据
	 *
	 * @param orkasgbProjectList 实体对象
	 * @return 操作结果
	 */
	@PostMapping("addOrUpdateOrkasgbProject")
	public CommonResult<Integer> addOrUpdateOrkasgbProject (@RequestBody List<OrkasgbProjectEntity> orkasgbProjectList) {
		return CommonResult.ofSuccess(orkasgbProjectService.addOrUpdateOrkasgbProject(orkasgbProjectList));
	}
	
	/**
	 * 删除数据
	 *
	 * @param idList 主键结合
	 * @return 删除结果
	 */
	@DeleteMapping("deleteOrkasgbProjectByIds")
	public CommonResult<Integer> deleteOrkasgbProjectByIds (@RequestParam("idList") List<Long> idList) {
		return CommonResult.ofSuccess(orkasgbProjectService.deleteOrkasgbProjectByIds(idList));
	}
	
}

